<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel common\models\EmployeePhotoSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Employee Photos');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="employee-photo-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a(Yii::t('app', 'Create Employee Photo'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?php
    try {
//        $gv =
    } catch (Exception $e) {
    }
    ?>
    <?= GridView::widget([
        'tableOptions' => ['class' => 'table table-condensed table-bordered table-striped table-hover'],
        'pager' => [
//            'class'          => GoPager::className(),
            'nextPageLabel'  => Yii::t('app', 'Next Page'),
            'prevPageLabel'  => Yii::t('app', 'Previous Page'),
            'firstPageLabel' => Yii::t('app', 'First Page'),
            'lastPageLabel'  => Yii::t('app', 'Last Page'),
            'options' => [
                'class' => 'pagination pagination-sm m-t-none m-b-none',
            ],
        ],
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\ActionColumn'],
            [
                'class' => 'yii\grid\SerialColumn',
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 25px;'],
            ],
            [
//                    'label' => Yii::t('app', 'Id'),
                'attribute' => 'id',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
            ],
            [
//                    'label' => Yii::t('app', 'Name'),
                'attribute' => 'employee_name',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
            ],
            [
                'attribute' => 'employee_number',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
            ],
//                'id',
//                'employee_number',
//                'employee_name',
//                'image_name',
//                'image_url:url',
            [
//                    'label' => Yii::t('app', 'Name'),
                'attribute' => 'image_name',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
            ],
            [
//                'label' => Yii::t('app', 'Domain'),
                'attribute' => 'image_url',
                'value'     => function ($model) {
                    return Html::a($model['image_url'], $model['image_url'], ['target' => '_blank']);
                },
                'format'    => 'raw',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
            ],
            [
                'attribute' => 'image_content_type',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
            ],
            [
                'label' => Yii::t('app', 'Image Data'),
                'attribute' => 'image_data',
                'value'     => function ($model) {
                    return \common\business\EhrHelper::getEmployeePhoto($model);
                },
                'format' => [
                    'image',
                    [
                        'width'=>'35',
                        'height'=>'35'
                    ]
                ],
//                'filter' => ArrayHelper::map(\common\models\kingdee\OrgAdmin::find()->all(), 'FID', 'FDISPLAYNAME_L2'),
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
            ],
            [
                'attribute' => 'image_width',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
            ],
            [
                'attribute' => 'image_height',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
            ],
//            [
//                'attribute' => 'image_source_url',
//                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
//                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
//            ],
//                [
//                    'attribute' => 'image_source_data',
//                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
//                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
//                ],
            // 'image_data',
            // 'image_width',
            // 'image_height',
            // 'image_source_url:url',
            // 'image_source_data',
            // 'memo',
            // 'created_by',
            // 'created_at',
            // 'updated_by',
            // 'updated_at',
            [
//                    'label' => Yii::t('app', 'Updated At'),
                'attribute' => 'updated_at',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
            ],
        ],
    ]); ?>
</div>
